<?php
if($_POST['usuario']&&$_POST['nombre']&&$_POST['clave1']){
		if(XSRF("admin-wmb.php")){
			if($Usuarios=$SQL->consulta(
			"INSERT INTO set_usuarios 
			 VALUES (NULL , '".clean($_POST['usuario'])."',
			  '".sha1($_POST['clave2'])."',
			  '".clean($_POST['nombre'])."',
			  '".clean($_POST['apeido'])."',
			  '".clean($_POST['sexo'])."',
			  '".clean($_POST['imagen'])."',
			  '".clean($_POST['email'])."',
			  '".clean($_POST['rango'])."');
			 ")){
			echo "<label class='titulo'>$_P[ucorrect]<br /></label>";
			}else{
			echo "<label class='titulo'>$_P[uerror]<br /></label>";
			}
			?><div  class="marco_est" style="border:dashed 1px #000;" >
             <a href="admin-wmb.php?modulo=usuarios" class="link-n">
<img src="imagenes/regresar.jpg"  border="none"/>
<?=$_P['return']?>
</a><?
		}
	}else{
	$Rangos=$SQL->consulta("SELECT id,label FROM set_rangos");
	if(!empty($Rangos)) foreach($Rangos as $rango) $rankslist.= "<option value='".$rango->id."'>".$rango->label."</option>";
?>
<script type="text/javascript">
<!--
var usrok=false;
function disponible(usr){
	form=document.registro;
	if(!form.usuario.value){
		alert("Llene todos lo campos");
	}else if(!usrok){
		mostrar('modulos/usuarios/procesador.php?usrcheck&usuario='+form.usuario.value,'usuario');
			setTimeout("checar();", 1000);
	}
}
function checar(){
form=document.registro;
var obj = document.getElementById('usuario');
alert(obj.innerHTML);
/*
if(obj.innerHTML=='OK'){
	usrcheck=true;
	alert("OK");
}else{
	alert("<?=$_P['inuse']?>");
}
*/
}
//-->
</script>
<label class='titulo'><?=$_P['new']." ".$_P['user']?><br /></label>
<div  class="marco_est" style="border:dashed 1px #000;" >
             <a href="admin-wmb.php?modulo=usuarios" class="link-n">
<img src="imagenes/regresar.jpg"  border="none"/>
<?=$_P['return']?>
</a>
<table width="280" border="0" cellpadding="0" cellspacing="0" style="background:#CCC;text-align:center; margin-left:75px;">
<div id="usuario" style="display:none"></div>
<form method="post" action="" name="registro">
<tr class="headers">
    <th  height="28"  style="text-align:right"><?=$_P['user']?> :</th>
    <td><input name="usuario" type="text" maxlength="10" autocomplete="off"  onchange="disponible(this.value);"/></td>
</tr>
<tr class="headers">
    <th  height="28"  style="text-align:right"><?=$_P['name']?> :</th>
    <td><input name="nombre" type="text" maxlength="20" autocomplete="off"/></td>
</tr>
<tr class="headers">
    <th  height="28"  style="text-align:right"><?=$_P['lastname']?> :</th>
    <td><input name="apeido" type="text" maxlength="20" autocomplete="off"/></td>
</tr>
<tr class="headers">
    <th  height="28"  style="text-align:right"><?=$_P['sex']?> :</th>
    <td>
    <select name="sexo">
		<option value='H' selected="selected"><?=$_P['man']?></option>
        <option value='M'><?=$_P['woman']?></option>
	</select>
    </td>
</tr>
<tr class="headers">
    <th  height="28"  style="text-align:right"><?=$_P['img']?> :</th>
    <td><input name="imagen" type="text" maxlength="1000" autocomplete="off"/></td>
</tr>
<tr class="headers">
    <th  height="28"  style="text-align:right"><?=$_P['password']?> :</th>
    <td><input name="clave1" type="password" autocomplete="off" /></td>
</tr>
<tr class="headers">
    <th  height="28"  style="text-align:right"><?=$_P['confirm']?> :</th>
    <td><input name="clave2" type="password" autocomplete="off"/></td>
</tr>
<tr class="headers">
    <th  height="28"  style="text-align:right"><?=$_P['email']?> :</th>
    <td><input name="email" type="text" maxlength="50" autocomplete="off"/></td>
</tr>
<tr class="headers">
    <th  height="28"  style="text-align:right"><?=$_P['rank']?> :</th>
    <td>
    <select name="rango">
    <option value="0" selected="selected"><?=$_P['without']." ".$_P['rank']?></option>
		<?=$rankslist?>
	</select>
	</td>
</tr>
<tr class="headers">
    <td  height="28"  colspan="2" style="text-align:center"><input type="button" onclick="crear();" name="enviar" value="<?=$_P['create']." ".$_P['user']?>" /></td>
</tr>
</form>
</table>
</div>
<?
}
?>